refactor(app): centralize sync query options#25941
Open
Hona wants to merge 5 commits intoanomalyco:devfrom
Open
refactor(app): centralize sync query options#25941Hona wants to merge 5 commits intoanomalyco:devfrom
Hona wants to merge 5 commits intoanomalyco:devfrom
Conversation
This was referenced May 6, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the app’s global sync context to centralize construction of TanStack query options (and associated SDK selection) behind a new useQueryOptions() hook, so components no longer need to directly choose between global vs directory SDK clients.
Changes:
- Add
queryOptionsApitoGlobalSyncand expose it viauseQueryOptions(). - Update components to consume query keys/options via
useQueryOptions()(e.g., MCP refetch + sessions fetching indicators). - Refactor
createChildStoreManagerto accept query option factories instead of a directory SDK getter.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/app/src/pages/layout/sidebar-workspace.tsx | Switch session fetching indicator to use queryOptions.sessions(...).queryKey. |
| packages/app/src/context/global-sync/child-store.ts | Replace getSdk(directory) with injected query option factories for per-directory queries. |
| packages/app/src/context/global-sync/child-store.test.ts | Update test harness to provide queryOptions instead of getSdk. |
| packages/app/src/context/global-sync.tsx | Introduce queryOptionsApi, wire it into child stores, and export useQueryOptions(). |
| packages/app/src/components/status-popover-body.tsx | Refetch MCP status using centralized query options rather than importing query key helpers. |
| packages/app/src/components/prompt-input.tsx | Route agents/providers queries through centralized query options (removes direct global SDK usage). |
| packages/app/src/components/dialog-select-mcp.tsx | Refetch MCP status using centralized query options rather than importing query key helpers. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+184
to
+187
| input.queryOptions.path(key), | ||
| input.queryOptions.mcp(key), | ||
| input.queryOptions.lsp(key), | ||
| input.queryOptions.providers(key), |
Comment on lines
+29
to
+34
| queryOptions: { | ||
| lsp: (directory: string) => ReturnType<typeof loadLspQuery> | ||
| mcp: (directory: string) => ReturnType<typeof loadMcpQuery> | ||
| path: (directory: string) => ReturnType<typeof loadPathQuery> | ||
| providers: (directory: string) => ReturnType<typeof loadProvidersQuery> | ||
| } |
| vcsCache: children.vcsCache.get(key), | ||
| loadLsp: () => { | ||
| void queryClient.fetchQuery(loadLspQuery(key, sdkFor(directory))) | ||
| void queryClient.fetchQuery(queryOptionsApi.lsp(key)) |
Comment on lines
+88
to
+93
| const queryOptionsApi = { | ||
| globalConfig: () => loadGlobalConfigQuery(globalSDK.client), | ||
| projects: () => loadProjectsQuery(globalSDK.client), | ||
| providers: (directory: string | null) => | ||
| loadProvidersQuery(directory, directory === null ? globalSDK.client : sdkFor(directory)), | ||
| path: (directory: string | null) => |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
useQueryOptions()so app components request sync query options without choosing global vs directory SDKs directlyqueryOptions.keysinstead of importing individual key helpersTesting
bun typecheckfrompackages/appbun --conditions=browser -e "<paused providers query repro>"bun turbo typecheck